package com.ruoyi.smartcity.anfang.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.smartcity.anfang.domain.AnfangCaiji;
import com.ruoyi.smartcity.anfang.service.IAnfangCaijiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 采集管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/smartcity/anfang/caiji")
public class AnfangCaijiController extends BaseController
{
    @Autowired
    private IAnfangCaijiService anfangCaijiService;

    /**
     * 查询采集管理列表
     */
    @RequiresPermissions("anfang:caiji:list")
    @GetMapping("/list")
    public TableDataInfo list(AnfangCaiji anfangCaiji)
    {
        startPage();
        List<AnfangCaiji> list = anfangCaijiService.selectAnfangCaijiList(anfangCaiji);
        return getDataTable(list);
    }

    /**
     * 导出采集管理列表
     */
    @RequiresPermissions("anfang:caiji:export")
    @Log(title = "采集管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnfangCaiji anfangCaiji)
    {
        List<AnfangCaiji> list = anfangCaijiService.selectAnfangCaijiList(anfangCaiji);
        ExcelUtil<AnfangCaiji> util = new ExcelUtil<AnfangCaiji>(AnfangCaiji.class);
        util.exportExcel(response, list, "采集管理数据");
    }

    /**
     * 获取采集管理详细信息
     */
    @RequiresPermissions("anfang:caiji:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(anfangCaijiService.selectAnfangCaijiById(id));
    }

    /**
     * 新增采集管理
     */
    @RequiresPermissions("anfang:caiji:add")
    @Log(title = "采集管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnfangCaiji anfangCaiji)
    {
        return toAjax(anfangCaijiService.insertAnfangCaiji(anfangCaiji));
    }

    /**
     * 修改采集管理
     */
    @RequiresPermissions("anfang:caiji:edit")
    @Log(title = "采集管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnfangCaiji anfangCaiji)
    {
        return toAjax(anfangCaijiService.updateAnfangCaiji(anfangCaiji));
    }

    /**
     * 删除采集管理
     */
    @RequiresPermissions("anfang:caiji:remove")
    @Log(title = "采集管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(anfangCaijiService.deleteAnfangCaijiByIds(ids));
    }
}
